package com.deng.api.controller;

import com.deng.api.entity.CloudRecruit;
import com.deng.api.service.ICloudRecruitService;
import com.deng.api.vo.DistributionVO;
import com.deng.api.vo.RecruitADDVO;
import com.deng.commons.common.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Set;

/**
 * <p>
 * 投递简历人员表 前端控制器
 * </p>
 *
 * @author deng
 * @since 2022-08-10
 */
@RestController
@Api(tags = "招聘管理接口")
@RequestMapping("/api/recruit")
public class CloudRecruitController {
    @Resource
    private ICloudRecruitService iCloudRecruitService;

    @ApiOperation("添加招聘信息")
    @PostMapping("/add")
    public BaseResult addRecruit(@RequestBody RecruitADDVO recruitADDVO){
        return BaseResult.result(iCloudRecruitService.add(recruitADDVO));
    }
    @ApiOperation("Excel导入招聘信息")
    @PostMapping("/import")
    public BaseResult importRecruit(MultipartFile file){
        return BaseResult.result(iCloudRecruitService.importRecruit(file));
    }
    @ApiOperation("获取招聘信息列表")
    @GetMapping("/all")
    public BaseResult getAll(@RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer size,
                             CloudRecruit recruit){
        return BaseResult.success(iCloudRecruitService.getAll(page,size,recruit));
    }
    @ApiOperation("删除招聘者信息")
    @PostMapping("/delete")
    public BaseResult deleteRecruit(@RequestBody Set<Long> ids){
        return iCloudRecruitService.deleteRecruit(ids);
    }
    @ApiOperation("资源分配")
    @PostMapping("/distribution")
    public BaseResult distribution(@RequestBody DistributionVO vo){
        return iCloudRecruitService.distribution(vo);
    }

    @ApiOperation("当前任务：新资源")
    @GetMapping("/getNew")
    public BaseResult getNew(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            CloudRecruit recruit){
        return iCloudRecruitService.getNew(page,size,recruit);
    }
}
